<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/news.css">
</head>
<body>
	<div class="bannerS">
		
		<!-- 导航栏 -->
	<div class="nav ">
		<div class="banner">
			<img src="https://www.buchouwang.com/img/logo.a2dacc49.png">
		</div>
		<div class="nav-center">
			<a href="./index.html" class="item-on">首页 <span></span></a>
			<a href="javascript:;" class="product">产品介绍 <span></span>
				<div class="Invisibility">
				<div class="subnav"></div>
			</div>
			</a>
			
			<a href="">解决方案 <span></span></a>
			<a href="">案例展示 <span></span></a>
			<a href="./news.html" class="news1">新闻中心 
				<span></span>
				<div class="Invisibility2">
				<div class="subnav2" >
					<div class="first-nav" onclick="subnav1(1)">
						<img src="./img/3.png">
						<p>公司动态</p>
					</div>
					<div class="secone-nav" onclick="subnav2(2)">
						<img src="./img/4.png">
						<p>行业动态</p>
					</div>
				</div>
				</div>
			</a>
			<a href="">关于我们 <span></span></a>
			<a href="">加入我们 
				<span></span>
			</a>
			<a href="">生猪交易 <span></span></a>
			<a href="">申请演示 <span></span></a>
		</div>
        	
	</div>
	<div class="bantie">
			<div class="bancon">
				<div class="banner-title"></div>
				<div class="banner-info"></div>
			</div>
		</div>
</div>
	<div class="detail-wrap">
		<div class="center-wrap">
			<div class="detail-title">
				首页>
				<span class="detail-title-name"></span>
			</div>
			<div class="detail-body clearfix">
				<div class="body-left">
					<ul class="newsbody">
						
					</ul>
					<div class="c-page">
						<div class="page-body">
							<span class="num">共 14 条</span>
							<button class="lestpage" disabled="disabled"><</button>
							<ul class="pageIndex">
								<li class="pagenumber action">1</li>
								<li class="pagenumber">2</li>
								<li class="pagenumber">3</li>
							</ul>
							<button class="nextpage">></button>
							<span class="pagejump">
								前往
								<input type="number" name="">
								页
							</span>
						</div>
					</div>
				</div>
			</div>
			<div class="body-right">
					<div class="body-right-title">
						推荐产品
					</div>
					<div class="body-right-text">
						<ul class="text-body">
							
						</ul>
					</div>
				</div>
		</div>
	</div>
	
	<script type="text/javascript" src="ajax.js"></script>
	<script type="text/javascript" src="jquery-3.2.1.js"></script>
	<script type="text/javascript">
		// console.log(location.href)
		// let id = location.href.split('=')[1];
		// function subnav2(id2){
		// 	location.href = `news.html?id2=${id2}`
		// }



			//二级导航
			let subnav = document.querySelector(".subnav")
			ajax({
			  method: "get",
			  url: "stage-api/website/getProductMenuInfo",
			}).then(res => {
			  for(let i = 0; i < res.data.length; i++){
			    if (i == 4) {
			      continue;
			    }else if(i == 6){
			      continue;
			    }else{
			      subnav.innerHTML += `<div class="subtag" onclick=detail('${res.data[i].productId}')>
			                            <img src=${res.data[i].menuIcon.split("?")[0]}>
			                            <p>${res.data[i].productName}</p >
			                            </div>`
			    }
			  }
			})
			

			  function detail(productId){
			    location.href = `po.html?productId=${productId}`
			  }
			  $(".product").hover(function(){
				  $(".Invisibility").css("display", "block")
				}, function(){
				  $(".Invisibility").css("display", "none")
				})
			  $(".news1").hover(function(){
				  $(".Invisibility2").css("display", "block")
				}, function(){
				  $(".Invisibility2").css("display", "none")
				})
			  function subnav1(newsType) {
			  	location.href = `news.html?newsType=1`
			  }

			  function subnav2(newsType) {
			  	location.href = `news.html?newsType=2`
			  }
			  //案例展示
			
			  let newhref = location.href

			    console.log(location.href)
			let bannertitle = document.querySelector('.banner-title')
			let bannerinfo = document.querySelector('.banner-info')
			let detailtitle = document.querySelector('.detail-title-name')
			let newbody = document.querySelector('.body-left .newsbody')
			console.log(newhref)
			if(newhref == 1){
			  bannertitle.innerText = "公司动态"
			  bannerinfo.innerText = "公司动态"
			  detailtitle.innerText = "公司动态"
			  ajax({
			  method: "get",
			  url: "stage-api/website/getNewsList",
			  params: {
			    pageNum: 1,
			    pageSize: 3,
			    newsType: 1,
			  },
			})
			  .then(res =>{
			    for(let i = 0; i < res.rows.length; i++){
			      newbody.innerHTML += `<li class="item-warp" onclick=newsmore1('${res.rows[i].newsId}')>
			                              <div class="item">
			                                <div class="item-img">
			                                  <img src="${res.rows[i].newsPic}">
			                                </div>
			                                <div class="item-text">
			                                  <div class="title">${res.rows[i].newsName}</div>
			                                  <div class="content">${res.rows[i].remark}</div>
			                                  <div class="time">${res.rows[i].createTime.split(" ")[0]}</div>
			                                </div>
			                              </div>
			                            </li>`
			    }
			  })
			}else{
			  bannertitle.innerText = "行业动态"
			  bannerinfo.innerText = "行业动态"
			  detailtitle.innerText = "行业动态"
			  ajax({
			  method: "get",
			  url: "stage-api/website/getNewsList",
			  params: {
			    pageNum: 1,
			    pageSize: 3,
			    newsType: 2,
			  },
			})
			  .then(res =>{
			    for(let i = 0; i < res.rows.length; i++){
			    	console.log(res.rows[i].newsId)
			      newbody.innerHTML += `<li class="item-warp" onclick=newsmore2('${res.rows[i].newsId}')>
			                              <div class="item">
			                                <div class="item-img">
			                                  <img src="${res.rows[i].newsPic}">
			                                </div>
			                                <div class="item-text">
			                                  <div class="title">${res.rows[i].newsName}</div>
			                                  <div class="content">${res.rows[i].remark}</div>
			                                  <div class="time">${res.rows[i].createTime.split(" ")[0]}</div>
			                                </div>
			                              </div>
			                            </li>`
			    }
			  })
			}


			function newsmore1(newsId) {
			  location.href = `newsmore1.html?newsId=${newsId}`
			}
			function newsmore2(newsId) {
			  location.href = `newsmore2.html?newsId=${newsId}`
			}

			let number = document.querySelectorAll('.pagenumber')
			number[1].onclick = function(){
			  number[0].className = "pagenumber"
			  number[2].className = "pagenumber"
			  this.className = "pagenumber active"
			  // $(this).addClass('.active').siblings().removeClass('active')
			  $(".page3").css("display","none")
			  $(".page1").css("display","none")
			  $(".page2").css("display","block")
			  $(".nextpage").attr("disabled", true)
			  $(".lestpage").attr("disabled", false)
			}
			number[0].onclick = function(){
			  number[1].className = "pagenumber"
			  number[2].className = "pagenumber"
			  this.className = "pagenumber active"
			  // $(this).addClass('.active').siblings().removeClass('active')
			  $(".page2").css("display","none")
			  $(".page1").css("display","block")
			  $(".page3").css("display","none")
			  $(".nextpage").attr("disabled", false)
			  $(".lestpage").attr("disabled", true)
			}
			number[2].onclick = function(){
			  number[1].className = "pagenumber"
			  number[0].className = "pagenumber"
			  this.className = "pagenumber active"
			  // $(this).addClass('.active').siblings().removeClass('active')
			  $(".page2").css("display","none")
			  $(".page3").css("display","block")
			  $(".page1").css("display","none")
			  $(".nextpage").attr("disabled", false)
			  $(".lestpage").attr("disabled", true)
			}
			let act = document.querySelector('.action')
			$(".nextpage").click(function() {
			  act.nextElementSibling.onclick()
			})
			$(".lestpage").click(function() {
			  act.previousElementSibling.onclick()
			})

			let rightitem = document.querySelector(".body-right-text .text-body")
			ajax({
			  method: "get",
			  url: "stage-api/website/getProductMenuInfo",

			})
			.then(res => {
			    for (let i = 0; i < res.data.length; i++) {
			      if (i <= 4) {
			        rightitem.innerHTML += `<li class="item-wrap">
			                                  <div class="item">
			                                    <img src="${res.data[i].logoPhotoAddress.split("?")[0]}">
			                                    <div class="item-right">
			                                      <div class="item-title">${res.data[i].productName}</div>
			                                      <div class="item-text">${res.data[i].productName}</div>
			                                    </div>
			                                  </div>
			                                </li>`
			      }else{
			        break;
			      }
			    }
			  })
	
	</script>
</body>
</html>